import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-20
 * Time: 13:31
 */
public class Test69 {
//    输入：num1 = [1,3], num2 = [2]
//    输出：2.00000
//    解释：合并数组 = [1,2,3] ，中位数 2
    public static double findMedianSortedArrays(int[] num1, int[] num2) {
        int m = num1.length, n = num2.length;
        int left = (m+n+1)/2;
        int right = (m+n+2)/2;
        return (getK(num1,0,m-1,num2,0,n-1,left) + getK(num1,0,m-1,num2,0,n-1,right)) * 0.5;
    }

    public static int getK(int[] num1,int st1,int end1,int[] num2, int st2,int end2,int k) {
        int len1 = end1-st1+1;
        int len2 = end2-st2+1;

        if(len1 > len2) {
            return getK(num2,st2,end2,num1,st1,end1,k);
        }

        if(len1 == 0) {
            return num2[st2+k-1];
        }

        if(k == 1) {
            return Math.min(num1[st1],num2[st2]);
        }
        int i = st1 + Math.min(len1,k/2)-1;
        int j = st2 + Math.min(len2,k/2)-1;
        if(num1[i] > num2[j]) {
            return getK(num1,st1,end1,num2,j+1,end2,k-(j-st1+1));
        }else {
            return getK(num1,i+1,end1,num2,st2,end2,k-(i-st1+1));
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num1 = new int[n];
        int m = sc.nextInt();
        int[] num2 = new int[m];
        for(int i = 0; i < n; i++) {
            num1[i] = sc.nextInt();
        }
        for(int j = 0; j < m; j++) {
            num2[j] = sc.nextInt();
        }
        double ret = findMedianSortedArrays(num1,num2);
        System.out.println(ret);
    }
}
